/**
 * 
 */
package info.angelloznicoud.ircdl.bean;

/**
 * @author ANGELLOZ-NICOUD Sébastien
 *
 * @version 1.0
 */
public class DownloadMessage {
	
	private String channel;
	
	private String server;
	
	private String message;
	
	private FileManager fileManager;
	
	public DownloadMessage(String channel, String server, String message, FileManager fileManager) {
		this.channel = channel;
		this.server  = server;
		this.message = message;
		this.fileManager = fileManager;
	}
	
	public String getBotName() {
		if (this.message.startsWith("/msg")) {
			return this.message.substring("/msg ".length(), this.message.indexOf(" xdcc"));
		} else if (this.message.startsWith("/ctcp")) {
			return this.message.substring("/ctcp ".length(), this.message.indexOf(" xdcc"));
		} else { 
			return null;
		}
	}
	
	public String getXdccCommand() {
		if (this.message.indexOf("xdcc get") != -1) {
			return this.message.substring(this.message.indexOf("xdcc get"));
		} else {
			return this.message.substring(this.message.indexOf("xdcc send"));
		}
	}
	
	public FileManager getFileManager() {
		return fileManager;
	}
	
	public String getAddress() {
		return this.channel + MessageFile.DELIMITER + this.server;
	}
	
	public String getChannel() {
		return channel;
	}
	
	public String getMessage() {
		return message;
	}
	
	public String getServer() {
		return server;
	}
	
	public void setChannel(String channel) {
		this.channel = channel;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}
	
	public void setServer(String server) {
		this.server = server;
	}
	
	@Override
	public String toString() {
		return this.server 
				+ MessageFile.DELIMITER 
				+ this.channel 
				+ MessageFile.DELIMITER 
				+ this.message;
	}

}
